-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate Openverse ESLint plugin to FlatConfig #5049
Conversation
dfe3263
to
7869270
Compare
Latest k6 run output1
Footnotes
|
55057e1
to
5e81870
Compare
b17ea33
to
26123ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! I tried a conversion like this a while ago and the flat config was not ready yet... but it has much nicer ergonomics for file inclusion/exclusion! There may be further simplifications possible to the just recipe and pre-commit hook in the future by re-evaluating how files are selected.
package.json
Outdated
"dependencies": { | ||
"typescript-eslint": "^8.8.1" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this dependency be a devDependency
instead? Or go into the eslint-plugin
package? Or does it need to go in the same package.json as typescript?
} | ||
|
||
Object.assign(plugin.configs, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use Object.assign
here rather than in-lining the configuration into plugin.configs
when it's created on line 21?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to enable referencing the openverse plugin in the config (to avoid circular imports): https://eslint.org/docs/latest/extend/plugins#configs-in-plugins
c1fe846
to
19ed8f1
Compare
I got an error when I ran
I'm using node v22.11.0. |
Looks like you need to update your ov environment: it is still using the old node. And the ESLint version logged is old, so you will also need to run |
Based on the medium urgency of this PR, the following reviewers are being gently reminded to review this PR: @krysal Excluding weekend1 days, this PR was ready for review 4 day(s) ago. PRs labelled with medium urgency are expected to be reviewed within 4 weekday(s)2. @obulat, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings. Footnotes
|
19ed8f1
to
f4a11c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was initially scared by the changes so thanks for the heads up that most of them are let
→ const
. I have commented on some cases of ESLint suppression that I felt can be resolved instead but the PR is good to go.
// eslint-disable-next-line no-constant-binary-expression | ||
const isDryRun = process.env.DRY_RUN === "true" ?? false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one caught my eye. Isn't ?? false
redundant here? It doesn't seem to have any effect on the value of the expression.
// eslint-disable-next-line no-constant-binary-expression | |
const isDryRun = process.env.DRY_RUN === "true" ?? false | |
// eslint-disable-next-line no-constant-binary-expression | |
const isDryRun = process.env.DRY_RUN === "true" ?? false |
frontend/tailwind.config.ts
Outdated
require("@tailwindcss/typography"), | ||
require("@tailwindcss/typography"), // eslint-disable-line @typescript-eslint/no-require-imports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to do this without the ESLint disable.
+ import tailwindcssTypography from "@tailwindcss/typography"
- require("@tailwindcss/typography"),
+ tailwindcssTypography,
f4a11c6
to
f046c6c
Compare
Signed-off-by: Olga Bulat <[email protected]>
Signed-off-by: Olga Bulat <[email protected]>
Signed-off-by: Olga Bulat <[email protected]>
Signed-off-by: Olga Bulat <[email protected]>
Signed-off-by: Olga Bulat <[email protected]>
Signed-off-by: Olga Bulat <[email protected]>
Signed-off-by: Olga Bulat <[email protected]>
Signed-off-by: Olga Bulat <[email protected]>
Signed-off-by: Olga Bulat <[email protected]>
This reverts commit 100ad14.
f046c6c
to
33cf326
Compare
True, duh! I overlooked that difference. It worked after updating |
Fixes
Fixes #4923 by @obulat
Description
This PR migrates the Openverse ESLint plugin to the FlatConfig that is used in ESLint version 9.
With this update, we remove many deprecated dependencies, improving security.
Most of the changed lines are replacing
let
withconst
(it appears thatprefer-const
rule was either not enabled or not used before this PR)Testing Instructions
Try removing some of the
eslint-disable
comments, and runningov just lint eslint
- you should see warnings loggedApply the following patch to test Openverse-specific rules, and then run
ov just lint eslint
. You should see warnings for@openverse/eslint-plugin
Openverse rules:
Edit: you can view these errors in the CI run (changes reverted in the most recent commit): https://github.com/WordPress/openverse/actions/runs/11498472780/job/32004338713?pr=5049
Patch to test @openverse/eslint-plugin rules
Subject: [PATCH] Openverse warnings
Index: frontend/test/unit/specs/components/AudioTrack/v-audio-track.spec.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/frontend/test/unit/specs/components/AudioTrack/v-audio-track.spec.js b/frontend/test/unit/specs/components/AudioTrack/v-audio-track.spec.js
--- a/frontend/test/unit/specs/components/AudioTrack/v-audio-track.spec.js (revision 145e88b)
+++ b/frontend/test/unit/specs/components/AudioTrack/v-audio-track.spec.js (date 1729769395077)
@@ -60,7 +60,7 @@
}
})
options.props.layout = "full"
const { getByRole } = await render(VAudioTrack, options)
const creator = getByRole("link", { name: props.audio.creator })
Index: packages/js/api-client/tests/client.test.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/packages/js/api-client/tests/client.test.ts b/packages/js/api-client/tests/client.test.ts
--- a/packages/js/api-client/tests/client.test.ts (revision 145e88b)
+++ b/packages/js/api-client/tests/client.test.ts (date 1729769443296)
@@ -21,7 +21,7 @@
describe("OpenverseClient", () => {
describe("api token refresh", async () => {
const { client, nock } = getClientAndNock({
clientId: "test",
clientSecret: "test-secret",
Index: frontend/src/types/analytics.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/frontend/src/types/analytics.ts b/frontend/src/types/analytics.ts
--- a/frontend/src/types/analytics.ts (revision 145e88b)
+++ b/frontend/src/types/analytics.ts (date 1729768336706)
@@ -53,6 +53,7 @@
*/
export type Events = {
/**
@@ -62,6 +63,7 @@
*/
SUBMIT_SEARCH: {
/** The media type being searched /
searchType: SearchType
/* The search term */
Index: frontend/src/locales/scripts/en.json5
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/frontend/src/locales/scripts/en.json5 b/frontend/src/locales/scripts/en.json5
--- a/frontend/src/locales/scripts/en.json5 (revision 145e88b)
+++ b/frontend/src/locales/scripts/en.json5 (date 1729769241187)
@@ -1,6 +1,6 @@
{
"404": {
main: "Go to {link} or search for something similar from the field below.",
},
hero: {
Index: frontend/test/playwright/e2e/all-results-analytics.spec.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/frontend/test/playwright/e2e/all-results-analytics.spec.ts b/frontend/test/playwright/e2e/all-results-analytics.spec.ts
--- a/frontend/test/playwright/e2e/all-results-analytics.spec.ts (revision 145e88b)
+++ b/frontend/test/playwright/e2e/all-results-analytics.spec.ts (date 1729769395074)
@@ -33,7 +33,7 @@
await goToSearchTerm(page, "birds")
})
context,
page,
}) => {
Index: packages/js/eslint-plugin/src/rules/analytics-configuration.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/packages/js/eslint-plugin/src/rules/analytics-configuration.ts b/packages/js/eslint-plugin/src/rules/analytics-configuration.ts
--- a/packages/js/eslint-plugin/src/rules/analytics-configuration.ts (revision 145e88b)
+++ b/packages/js/eslint-plugin/src/rules/analytics-configuration.ts (date 1729768071865)
@@ -40,14 +40,8 @@
return true
}
}
const getPropertyName = (node: TSESTree.TSPropertySignature): string => {
Checklist
Update index.md
).main
) or a parent feature branch.ov just catalog/generate-docs
for catalogPRs) or the media properties generator (
ov just catalog/generate-docs media-props
for the catalog or
ov just api/generate-docs
for the API) where applicable.Developer Certificate of Origin
Developer Certificate of Origin